package com.bjqh.edu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;

import com.bjqh.edu.Base.AppConstants;
import com.bjqh.edu.Bean.Index;
import com.bjqh.edu.R;
import com.bumptech.glide.Glide;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/9/25.
 */

public class IndexTeacherAdapter extends BaseAdapter {
    private List<Index.TeacherBeanX> list;
    private Context ctx;
    private ViewHolder holder;

    public IndexTeacherAdapter(Context ctx, List<Index.TeacherBeanX> data) {
        this.ctx = ctx;
        this.list = data;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = LayoutInflater.from(ctx).inflate(R.layout.item_index_teacher, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        Glide.with(ctx)
                .load(AppConstants.IMG_URL + list.get(i).getHeader())
                .error(R.mipmap.ls)
                .into(holder.ivTeacher);

        return view;
    }

    static


    class ViewHolder {
        @BindView(R.id.iv_teacher)
        ImageView ivTeacher;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
